package stsj.meddroid;

import java.util.HashMap;

import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

public class Resources {
	
	public static final int GOLD  = 3;
	public static final int SILVER = 2;
	public static final int BRONZE = 1;
//
//	private static final int SLIME = 0;
//	private static final int DURI = 1;
//	private static final int GEBUK = 2;
//	private static final int PETELUR = 3;

	public static final int SLIME_GREEN = 0;
	public static final int SLIME_BLUE = 1;
	public static final int SLIME_RED = 2;
	public static final int SLIME_ORANGE = 3;

	public static final int DURI_GREEN = 0;
	public static final int DURI_ORANGE = 1;
	public static final int DURI_VIOLET = 2;

	public static final int GEBUK_GREEN = 0;
	public static final int GEBUK_PINK = 1;
	public static final int GEBUK_RED = 2;

	public static final int PETELUR_BLUE = 0;
	public static final int PETELUR_VIOLET = 1;
	public static final int PETELUR_YELLOW = 2;
	
	public static final int RBJ = 0;
	public static final int SPT = 1;
	public static final int HTN = 2;
	public static final int SMC = 3;
	
	
	public static boolean finish = false;
	public static SpriteBatch batch ;

	public static Camera camera ;
	
	public static final int VP_WIDTH = 480;
	public static final int VP_HEIGHT = 320;
	
	public static MainAppListener mainListener;
	
	/// ---------------------------------------
	
	public static Texture buttonDll;
	public static Texture storyhelpscreen;
	public static Texture playerdialog;
	public static Texture kuman;
	public static Texture organmenulayout;
	
	
//	/ ---------------------------------------
	
	public static Texture starMedalTex;
	public static TextureRegion starMedal[];
	
	
	public static Texture angka;
	
	// Main Menu
	
	
	public static TextureRegion playRegion[];
	public static TextureRegion backgroundRegion;
	public static TextureRegion viroRegion[];
	public static TextureRegion creditRegion[];
	public static TextureRegion soundRegion[];

//	public static TextureRegion playRegion2;
//	public static TextureRegion viroRegion2;
//	public static TextureRegion creditRegion2;
//	public static TextureRegion soundRegion2;

	public static TextureRegion exitDialogRegion;
	public static TextureRegion yesRegion[];
//	public static TextureRegion yesRegion2;
	public static TextureRegion noRegion[];
//	public static TextureRegion noRegion2;

	// Stage Selection

//	
	
	
	public static TextureRegion backButton [];
	public static TextureRegion bgStageSelectRegion;


	// round
	
	
	public static TextureRegion roundLocked;
	public static TextureRegion medal[];
	
	// stage 01 - round

	public static TextureRegion stage01Region[];
	public static TextureRegion stage02Region[];
	public static TextureRegion stage03Region[];
	public static TextureRegion stage04Region[];
	public static TextureRegion stage05Region[];
	
	public static TextureRegion stage01Region2[];
	public static TextureRegion stage02Region2[];
	public static TextureRegion stage03Region2[];
	public static TextureRegion stage04Region2[];
	public static TextureRegion stage05Region2[];
	
	
//	public static TextureRegion stage0101Region;
//	public static TextureRegion stage0102Region;
//	public static TextureRegion stage0103Region;
//	public static TextureRegion stage0104Region;
//	public static TextureRegion stage0105Region;
//
//	public static TextureRegion stage0101Region2;
//	public static TextureRegion stage0102Region2;
//	public static TextureRegion stage0103Region2;
//	public static TextureRegion stage0104Region2;
//	public static TextureRegion stage0105Region2;
//
//	// stage 02 - round
//	public static TextureRegion stage0201Region;
//	public static TextureRegion stage0202Region;
//	public static TextureRegion stage0203Region;
//	public static TextureRegion stage0204Region;
//	public static TextureRegion stage0205Region;
//
//	public static TextureRegion stage0201Region2;
//	public static TextureRegion stage0202Region2;
//	public static TextureRegion stage0203Region2;
//	public static TextureRegion stage0204Region2;
//	public static TextureRegion stage0205Region2;
//
//	// stage 03 - round;
//	public static TextureRegion stage0301Region;
//	public static TextureRegion stage0302Region;
//	public static TextureRegion stage0303Region;
//	public static TextureRegion stage0304Region;
//	public static TextureRegion stage0305Region;
//
//	public static TextureRegion stage0301Region2;
//	public static TextureRegion stage0302Region2;
//	public static TextureRegion stage0303Region2;
//	public static TextureRegion stage0304Region2;
//	public static TextureRegion stage0305Region2;
//
//	// stage 04 - round;
//	public static TextureRegion stage0401Region;
//	public static TextureRegion stage0402Region;
//	public static TextureRegion stage0403Region;
//	public static TextureRegion stage0404Region;
//	public static TextureRegion stage0405Region;
//
//	public static TextureRegion stage0401Region2;
//	public static TextureRegion stage0402Region2;
//	public static TextureRegion stage0403Region2;
//	public static TextureRegion stage0404Region2;
//	public static TextureRegion stage0405Region2;
//
//	// stage 05 - round;
//	public static TextureRegion stage0501Region;
//	public static TextureRegion stage0502Region;
//	public static TextureRegion stage0503Region;
//	public static TextureRegion stage0504Region;
//	public static TextureRegion stage0505Region;
//
//	public static TextureRegion stage0501Region2;
//	public static TextureRegion stage0502Region2;
//	public static TextureRegion stage0503Region2;
//	public static TextureRegion stage0504Region2;
//	public static TextureRegion stage0505Region2;

	// Battle Resources
	public static Texture texB;
	public static Texture texLaser;
	
	
//	public static TextureRegion texBrain;
//	public static TextureRegion texKidney;
//	public static TextureRegion texLiver;
//	public static TextureRegion texLung;
	
	public static Texture texTime;	
	
//	public static TextureRegion texBlueSlime;
//	public static TextureRegion texGreenSlime;
//	public static TextureRegion texOrangeSlime;
//	public static TextureRegion texRedSlime;
//	public static TextureRegion texLittleGomu;
//	public static TextureRegion texGomuGomu;
//	public static TextureRegion texGomuKing;
//	public static TextureRegion texBoguriWarrior;
//	public static TextureRegion texBoguriChieftain;
//	public static TextureRegion texInsaneBoguri;
//	public static TextureRegion texBlueRepetol;
//	public static TextureRegion texRedRepetol;
//	public static TextureRegion texVioletRepetol;
	
	public static Texture texBlueSlime;
	public static Texture texGreenSlime;
	public static Texture texOrangeSlime;
	public static Texture texRedSlime;
	public static Texture texLittleGomu;
	public static Texture texGomuGomu;
	public static Texture texGomuKing;
	public static Texture texBoguriWarrior;
	public static Texture texBoguriChieftain;
	public static Texture texInsaneBoguri;
	public static Texture texBlueRepetol;
	public static Texture texRedRepetol;
	public static Texture texVioletRepetol;
	
	public static Texture texBlack;
	public static Texture texBlack2;
	public static Texture texBlack3;
	public static Texture texBlack4;
	

	// Battle Menu Resources
	
	
//	public static TextureRegion battleDialog;
//	public static TextureRegion winDialog;
//	public static TextureRegion failedDialog;
//
//	public static TextureRegion[] helpButton;
//	public static TextureRegion[] retryButton;
//	public static TextureRegion[] returnPlayButton;
//	public static TextureRegion[] mainMenuButton;;
//	
//	
//	public static TextureRegion nextRoundButton[];
	

	// Story Tutorial Resources
	public static Texture storyEndingTex;
	public static TextureRegion story[];
	public static TextureRegion help [];
	public static TextureRegion helpMenuBg;
	// credit
	
	public static TextureRegion credit1;
	public static TextureRegion credit2;
	
	public static Texture henshinTex;
	public static TextureRegion henshin[];
	
	// Viro Resources
	
		
//	public static TextureRegion viroClose [];
//	public static TextureRegion viroLocked [];
//	
//
//	public static TextureRegion viroUnknown;
//	public static TextureRegion viroBookBg;
//	public static TextureRegion viroBack [];
//	public static TextureRegion viroForward [];
//	public static TextureRegion slimeBlue [];
//	public static TextureRegion slimeRed [];
//	public static TextureRegion slimeGreen [];
//	public static TextureRegion slimeOrange[];
//
//	public static TextureRegion duriOrange[];
//	public static TextureRegion duriGreen[];
//	public static TextureRegion duriViolet[];
//	
//	public static TextureRegion gebukPink[];
//	public static TextureRegion gebukGreen[];
//	public static TextureRegion gebukRed[];
//	
//	public static TextureRegion petelurBlue[];
//	public static TextureRegion petelurViolet[];
//	public static TextureRegion petelurYellow[];
//	
//	public static TextureRegion blackRBJ[];
//	public static TextureRegion blackSPT[];
//	public static TextureRegion blackHTN[];
//	public static TextureRegion blackSMC[];
//	
//	
//	public static TextureRegion viroSlimeBlue;
//	public static TextureRegion viroSlimeGreen;
//	public static TextureRegion viroSlimeRed;
//	public static TextureRegion viroSlimeOrange;
//	
//	public static TextureRegion viroDuriGreen;
//	public static TextureRegion viroDuriOrange;
//	public static TextureRegion viroDuriViolet;
//	
//	public static TextureRegion viroGebukGreen;
//	public static TextureRegion viroGebukPink;
//	public static TextureRegion viroGebukRed;
//	
//	public static TextureRegion viroPetelurBlue;
//	public static TextureRegion viroPetelurViolet;
//	public static TextureRegion viroPetelurYellow;
//	
//	public static TextureRegion viroBlackRBJ;
//	public static TextureRegion viroBlackSPT;
//	public static TextureRegion viroBlackHTN;
//	public static TextureRegion viroBlackSMC;
//	
//	
//	
//	public static TextureRegion viroTextSlime[];
//	public static TextureRegion viroTextDuri[];
//	public static TextureRegion viroTextGebuk[];
//	public static TextureRegion viroTextPetelur[];
//	public static TextureRegion viroTextBlack[];
	
	public static Texture viroText;
	
	
	// Sound Resources
	public static Sound clickSound;
	public static Sound backSound;
	public static Sound lockedSound;
	public static Sound orbSound;
	public static Sound timeUpSound;
	public static Sound petelurSound;
	public static Sound punchNoHitSound;
	public static Sound loseSound;
	public static Sound swingSound;
	
	

	public static Music bgmOpening;
	public static Music bgmViroBook;
	public static Music bgmEnding;
	public static Music bgmBoss;
	public static Music bgmBattle;
	public static Music bgmStory;
	
//	public static AndroidAudio swingSound;
	


		
	// lain-lain

	

	public static TextureRegion angkaMerah[];
	public static TextureRegion angkaHijau[];
	
	
	public static TextureRegion hurufKecil[];
	public static TextureRegion hurufBesar[];
	
	public static TextureRegion[] kataLoadings;
	public static TextureRegion stageTex;
	public static TextureRegion roundTex;
	
//	public static TextureRegion texImmunity;
	
	public static Texture texImmunity;
	public static Texture texNewModePlayer;
	public static Texture texNewModeButton;
	
	                               
	
	
	static {

		Gdx.app.log("Static init", "==");
		camera = new OrthographicCamera(VP_WIDTH,VP_HEIGHT);
		camera.position.set(VP_WIDTH/2,VP_HEIGHT/2,0);
		
		batch = new SpriteBatch();
		
		angka = new Texture(Gdx.files.internal("dll/angka.png"));
		angkaMerah = new TextureRegion[11];
		angkaHijau = new TextureRegion[11];

		for (int i = 0; i <= 10; i++) {
			angkaMerah[i] = new TextureRegion(angka, i * 32, 0, 32, 32);
			angkaHijau[i] = new TextureRegion(angka, i * 32, 32, 32, 32);
		}
		
//		huruf = new Texture (Gdx.files.internal("dll/huruf.png"));
//		hurufKecil = new TextureRegion[27];
//		hurufBesar = new TextureRegion[27];
//		
//		
//		for (int i = 0; i <= 25; i++) {
//			hurufKecil[i+1] = new TextureRegion(huruf, i * 32, 0, 32, 32);
//			hurufBesar[i+1] = new TextureRegion(huruf, i * 32, 32, 32, 32);
//		}
		
		Gdx.app.log("Static init", "==");
		
	}

	public static void load() {
		
	}

	public synchronized static void initMenu() {

		Gdx.app.log("LOADING", String.valueOf(1));

		// initialize texture for main menu
		buttonDll = new Texture(Gdx.files.internal("button/buttondll.png"));
		storyhelpscreen = new Texture(Gdx.files.internal("storyhelpscreen.png"));
		playerdialog = new Texture(Gdx.files.internal("dll/playerdialogloading.png"));
		kuman = new Texture(Gdx.files.internal("kuman/kuman.png"));
		organmenulayout = new Texture(Gdx.files.internal("organ.png"));
		
		starMedalTex =new Texture(Gdx.files.internal("starmedal.png"));
		
		starMedal = new TextureRegion[4];
		starMedal[1] = new TextureRegion(starMedalTex,0,0,64,64);
		starMedal[2] = new TextureRegion(starMedalTex,64,0,64,64);
		starMedal[3] = new TextureRegion(starMedalTex,64*2,0,64,64);
		
		
		exitDialogRegion = new TextureRegion(playerdialog, 256, 256, 256, 128);
		
		yesRegion = new TextureRegion[2];
		noRegion = new TextureRegion[2];
		

		yesRegion[0] = new TextureRegion(buttonDll, 64*6, 64*3, 64, 32);
		yesRegion[1] = new TextureRegion(buttonDll, 64*6, 64*3+32, 64, 32);
		
		noRegion[0] = new TextureRegion(buttonDll, 64*6, 64*2+32, 64, 32);
		noRegion[1] = new TextureRegion(buttonDll, 64*7, 64*2+32, 64, 32);

		
//		yesRegion = new TextureRegion(buttonDll, 64*6, 64*3, 64, 32);
//		yesRegion2 = new TextureRegion(buttonDll, 64*6, 64*3+32, 64, 32);
//		
//		noRegion = new TextureRegion(buttonDll, 64*6, 64*2+32, 64, 32);
//		noRegion2 = new TextureRegion(buttonDll, 64*7, 64*2+32, 64, 32);

		backgroundRegion = new TextureRegion(storyhelpscreen, 0, 320*5, 480, 320);
		
		playRegion = new TextureRegion[2];
		viroRegion = new TextureRegion[2];
		creditRegion = new TextureRegion[2];
		soundRegion = new TextureRegion[2];
		
		
		playRegion[0] = new TextureRegion(buttonDll, 64*8, 0, 128, 160);
		viroRegion[0]  = new TextureRegion(buttonDll, 64*8, 160, 128, 160);
		creditRegion[0]  = new TextureRegion(buttonDll, 64*4, 64*5, 64, 64);
		soundRegion[0]  = new TextureRegion(buttonDll, 64*4, 64*6, 64, 64);

		playRegion[1] = new TextureRegion(buttonDll, 64*10, 0, 128, 160);
		viroRegion[1] = new TextureRegion(buttonDll, 64*10, 160, 128, 160);
		creditRegion[1] = new TextureRegion(buttonDll, 64*5, 64*5, 64, 64);
		soundRegion[1] = new TextureRegion(buttonDll, 64*5, 64*6, 64, 64);
		
//
//		playRegion = new TextureRegion(buttonDll, 64*8, 0, 128, 160);
//		viroRegion = new TextureRegion(buttonDll, 64*8, 160, 128, 160);
//		creditRegion = new TextureRegion(buttonDll, 64*4, 64*5, 64, 64);
//		soundRegion = new TextureRegion(buttonDll, 64*4, 64*6, 64, 64);
//
//		playRegion2 = new TextureRegion(buttonDll, 64*10, 0, 128, 160);
//		viroRegion2 = new TextureRegion(buttonDll, 64*10, 160, 128, 160);
//		creditRegion2 = new TextureRegion(buttonDll, 64*5, 64*5, 64, 64);
//		soundRegion2 = new TextureRegion(buttonDll, 64*5, 64*6, 64, 64);
		
		backButton = new TextureRegion[2];
		backButton[0] = new TextureRegion(buttonDll,64*6,0,64,64);
		backButton[1] = new TextureRegion(buttonDll,64*7,0,64,64);
		
		
		// credit
		
		Texture creditTex1 = new Texture(Gdx.files.internal("credit1.png"));
		Texture creditTex2 = new Texture(Gdx.files.internal("credit2.png"));
//		
		
		credit1 = new TextureRegion(creditTex1,0,0,1653,320);
		credit2 = new TextureRegion(creditTex2,0,0,1955,320);
//		credit = new TextureRegion(creditTex,0,0,480,320);
		
		
		// viro book
		viroText =  new Texture (Gdx.files.internal("virobooktext.png"));
		
//		viroBack = new TextureRegion[2];
//		viroBack[0] = new TextureRegion(buttonDll,64*6,0,64,64);
//		viroBack[1] = new TextureRegion(buttonDll,64*7,0,64,64);
//		
//		
//		
//		viroForward = new TextureRegion[2];
//		viroForward[0] = new TextureRegion(buttonDll,64*6,0,64,64);
//		viroForward[1] = new TextureRegion(buttonDll,64*7,0,64,64);
//		viroForward[0].flip(true, false);
//		viroForward[1].flip(true, false);
//		
//		
//		viroClose = new TextureRegion[2];
//		viroClose[0] = new TextureRegion(buttonDll,64*6,64,32,32);
//		viroClose[1] = new TextureRegion(buttonDll,64*6 + 32,64,32,32);
//		
//		
//			
//			
//			 viroLocked = new TextureRegion[2];
//			 viroLocked[0] = new TextureRegion(buttonDll,64*4,64*7,64,64);
//			 viroLocked[1] = new TextureRegion(buttonDll,64*5,64*7,64,64);
//				
//			 viroBookBg=new TextureRegion(organmenulayout,512,1024,480,320);
//			 
//			 slimeBlue = new TextureRegion[2]; 
//			 slimeRed = new TextureRegion[2]; 
//			 slimeGreen = new TextureRegion[2]; 
//			 slimeOrange= new TextureRegion[2]; 
//
//			 duriOrange= new TextureRegion[2]; 
//			 duriGreen= new TextureRegion[2]; 
//			 duriViolet= new TextureRegion[2]; 
//			
//			 gebukPink= new TextureRegion[2]; 
//			 gebukGreen= new TextureRegion[2]; 
//			 gebukRed= new TextureRegion[2]; 
//			
//			 petelurBlue= new TextureRegion[2]; 
//			 petelurViolet= new TextureRegion[2]; 
//			 petelurYellow= new TextureRegion[2]; 
//			 
//			 blackRBJ= new TextureRegion[2]; 
//			 blackSPT= new TextureRegion[2]; 
//			 blackHTN= new TextureRegion[2]; 
//			 blackSMC= new TextureRegion[2]; 
//			 
//			 slimeGreen[0] = new TextureRegion(buttonDll,0,64*3,64,64);
//			 slimeGreen[1] = new TextureRegion(buttonDll,64,64*3,64,64);
//			 slimeBlue[0] = new TextureRegion(buttonDll,64,64,64,64);
//			 slimeBlue[1] = new TextureRegion(buttonDll,0,64,64,64);
//			 slimeRed[0] = new TextureRegion(buttonDll,0,0,64,64);
//			 slimeRed[1] = new TextureRegion(buttonDll,64,0,64,64);
//			 slimeOrange[0] = new TextureRegion(buttonDll,0,64*2,64,64);
//			 slimeOrange[1] = new TextureRegion(buttonDll,64,64*2,64,64);
//			 
//			 duriOrange[0] = new TextureRegion(buttonDll,0,64*4,64,64);
//			 duriOrange[1] = new TextureRegion(buttonDll,64,64*4,64,64);
//			 duriGreen[0] = new TextureRegion(buttonDll,0,64*6,64,64);
//			 duriGreen[1] = new TextureRegion(buttonDll,64,64*6,64,64);
//			 duriViolet[0] = new TextureRegion(buttonDll,0,64*5,64,64);
//			 duriViolet[1] = new TextureRegion(buttonDll,64,64*5,64,64);
//			 
//			 gebukPink[0] = new TextureRegion(buttonDll,0,64*7,64,64);
//			 gebukPink[1] = new TextureRegion(buttonDll,64,64*7,64,64);
//			 gebukGreen[0] = new TextureRegion(buttonDll,128,64,64,64);
//			 gebukGreen[1] = new TextureRegion(buttonDll,64*3,64,64,64);
//			 gebukRed[0] = new TextureRegion(buttonDll,128,0,64,64);
//			 gebukRed[1] = new TextureRegion(buttonDll,128+64,0,64,64);
//			 
//			 petelurBlue[0] = new TextureRegion(buttonDll,128,64*4,64,64);
//			 petelurBlue[1] = new TextureRegion(buttonDll,64*3,64*4,64,64);
//			 petelurViolet[0] = new TextureRegion(buttonDll,128,128,64,64);
//			 petelurViolet[1] = new TextureRegion(buttonDll,64*3,64*2,64,64);
//			 petelurYellow[0] = new TextureRegion(buttonDll,128,64*3,64,64);
//			 petelurYellow[1] = new TextureRegion(buttonDll,64*3,64*3,64,64);
//			 
//			 blackRBJ[0] = new TextureRegion(buttonDll,128,64*5,64,64);
//			 blackRBJ[1] = new TextureRegion(buttonDll,64*3,64*5,64,64);
//			 blackSPT[0] = new TextureRegion(buttonDll,128,64*6,64,64);
//			 blackSPT[1] = new TextureRegion(buttonDll,64*3,64*6,64,64);
//			 blackHTN[0] = new TextureRegion(buttonDll,128,64*7,64,64);
//			 blackHTN[1] = new TextureRegion(buttonDll,64*3,64*7,64,64);
//			 blackSMC[0] = new TextureRegion(buttonDll,64*4,0,64,64);
//			 blackSMC[1] = new TextureRegion(buttonDll,64*5,0,64,64);
//			 
//			 
//				 viroSlimeBlue=new TextureRegion(kuman,0,0,128,128);
//				 viroSlimeGreen=new TextureRegion(kuman,128*2,0,128,128);
//				 viroSlimeRed=new TextureRegion(kuman,128,0,128,128);
//				 viroSlimeOrange=new TextureRegion(kuman,128*3,0,128,128);
//				
//				 viroDuriGreen=new TextureRegion(kuman,0,128*2,128,128);
//				 viroDuriOrange=new TextureRegion(kuman,128,128*2,128,128);
//				 viroDuriViolet=new TextureRegion(kuman,128*2,128*2,128,128);
//				
//				 viroGebukGreen=new TextureRegion(kuman,128*3,128*2,128,128);
//				 viroGebukPink=new TextureRegion(kuman,0,128*3,128,128);
//				 viroGebukRed=new TextureRegion(kuman,128*1,128*3,128,128);
//				
//				 viroPetelurBlue=new TextureRegion(kuman,128*2,128*3,128,128);
//				 viroPetelurViolet=new TextureRegion(kuman,128*3,128*3,128,128);
//				 viroPetelurYellow=new TextureRegion(kuman,0,128*4,128,128);
//			 
//				 viroBlackRBJ = new TextureRegion(kuman,0,128,128,128);
//				 viroBlackSPT = new TextureRegion(kuman,128,128,128,128);
//				 viroBlackHTN = new TextureRegion(kuman,128*2,128,128,128);
//				 viroBlackSMC = new TextureRegion(kuman,128*3,128,128,128);
//				 
//	
//			
//			viroTextSlime = new TextureRegion[5];
//			viroTextSlime[SLIME_GREEN] = new TextureRegion(viroText,0,0,160,160);
//			viroTextSlime[SLIME_ORANGE] = new TextureRegion(viroText,161,0,160,160);
//			viroTextSlime[SLIME_RED] = new TextureRegion(viroText,322,0,160,160);
//			viroTextSlime[SLIME_BLUE] = new TextureRegion(viroText,483,0,160,160);
//			viroTextDuri = new TextureRegion[5];
//			viroTextDuri[DURI_GREEN] = new TextureRegion(viroText,644,0,160,160);
//			viroTextDuri[DURI_VIOLET] = new TextureRegion(viroText,0,160,160,160);
//			viroTextDuri[DURI_ORANGE] = new TextureRegion(viroText,161,160,160,160);
//			
//			
//			viroTextGebuk = new TextureRegion[5];
//			viroTextGebuk[GEBUK_GREEN] = new TextureRegion(viroText,322,160,160,160);
//			viroTextGebuk[GEBUK_RED] = new TextureRegion(viroText,483,160,160,160);
//			viroTextGebuk[GEBUK_PINK] = new TextureRegion(viroText,645,160,160,160);
//			viroTextPetelur = new TextureRegion[5];
//			viroTextPetelur[PETELUR_BLUE] = new TextureRegion(viroText,0,320,160,160);
//			viroTextPetelur[PETELUR_VIOLET] = new TextureRegion(viroText,322,320,160,160);
//			viroTextPetelur[PETELUR_YELLOW] = new TextureRegion(viroText,161,320,160,160);
//			
//			viroTextBlack = new TextureRegion[5];
//			viroTextBlack[RBJ] = new TextureRegion(viroText,483,320,160,160);
//			viroTextBlack[SPT] = new TextureRegion(viroText,645,320,160,160);
//			viroTextBlack[HTN] = new TextureRegion(viroText,0,480,160,160);
//			viroTextBlack[SMC] = new TextureRegion(viroText,161,480,160,160);
//			
//			
//			
			
	}

	public static void initStages() {
		Gdx.app.log("LOADING", String.valueOf(2));

		
		medal = new TextureRegion[4];
		medal[BRONZE] = new TextureRegion(buttonDll,64*7,64*3,64,64);
		medal[SILVER] = new TextureRegion(buttonDll,64*6,64*4,64,64);
		medal[GOLD] = new TextureRegion(buttonDll,64*7,64*4,64,64);
		
		stageTex = new TextureRegion(organmenulayout,0,1024+320+450,90*9,180);
		
		roundTex = new TextureRegion(organmenulayout,0,1024+320,90*11,450);
		bgStageSelectRegion = new TextureRegion(storyhelpscreen, 480,320*5, 480,
				320);
		
		

		// initialize texture for round selection menu
		Gdx.app.log("LOADING", String.valueOf(3));
		
		roundLocked = new TextureRegion(roundTex, 900, 2, 90, 90);

		stage01Region = new TextureRegion[6];
		stage02Region = new TextureRegion[6];
		stage03Region = new TextureRegion[6];
		stage04Region = new TextureRegion[6];
		stage05Region = new TextureRegion[6];
		
		stage01Region2 = new TextureRegion[6];
		stage02Region2 = new TextureRegion[6];
		stage03Region2 = new TextureRegion[6];
		stage04Region2 = new TextureRegion[6];
		stage05Region2 = new TextureRegion[6];
		
		
		// round 01
//		stage01Region[1] = new TextureRegion(roundTex, 0, 0, 90, 90);
//		stage01Region[2] = new TextureRegion(roundTex, 0, 90, 90, 90);
//		stage01Region[3] = new TextureRegion(roundTex, 0, 180, 90, 90);
//		stage01Region[4] = new TextureRegion(roundTex, 0, 270, 90, 90);
//		stage01Region[5] = new TextureRegion(roundTex, 0, 360, 90, 90);
//
//		stage01Region2[1] = new TextureRegion(roundTex, 90, 0, 90, 90);
//		stage01Region2[2] = new TextureRegion(roundTex, 90, 90, 90, 90);
//		stage01Region2[3] = new TextureRegion(roundTex, 90, 180, 90, 90);
//		stage01Region2[4] = new TextureRegion(roundTex, 90, 270, 90, 90);
//		stage01Region2[5] = new TextureRegion(roundTex, 90, 360, 90, 90);
//
//		// round 02
//		stage02Region[1] = new TextureRegion(roundTex, 180, 0, 90, 90);
//		stage02Region[2] = new TextureRegion(roundTex, 180, 90, 90, 90);
//		stage02Region[3] = new TextureRegion(roundTex, 180, 180, 90, 90);
//		stage02Region[4] = new TextureRegion(roundTex, 180, 270, 90, 90);
//		stage02Region[5] = new TextureRegion(roundTex, 180, 360, 90, 90);
//
//		stage02Region2[1] = new TextureRegion(roundTex, 270, 0, 90, 90);
//		stage02Region2[2] = new TextureRegion(roundTex, 270, 90, 90, 90);
//		stage02Region2[3] = new TextureRegion(roundTex, 270, 180, 90, 90);
//		stage02Region2[4] = new TextureRegion(roundTex, 270, 270, 90, 90);
//		stage02Region2[5] = new TextureRegion(roundTex, 270, 360, 90, 90);
//
//		// round 03
//		stage03Region[1] = new TextureRegion(roundTex, 360, 0, 90, 90);
//		stage03Region[2] = new TextureRegion(roundTex, 360, 90, 90, 90);
//		stage03Region[3] = new TextureRegion(roundTex, 360, 180, 90, 90);
//		stage03Region[4] = new TextureRegion(roundTex, 360, 270, 90, 90);
//		stage03Region[5] = new TextureRegion(roundTex, 360, 360, 90, 90);
//
//		stage03Region2[1] = new TextureRegion(roundTex, 450, 0, 90, 90);
//		stage03Region2[2] = new TextureRegion(roundTex, 450, 90, 90, 90);
//		stage03Region2[3] = new TextureRegion(roundTex, 450, 180, 90, 90);
//		stage03Region2[4] = new TextureRegion(roundTex, 450, 270, 90, 90);
//		stage03Region2[5] = new TextureRegion(roundTex, 450, 360, 90, 90);

		// round 04
		
		for (int i = 1; i<= 5; i++){
			stage01Region[i] = new TextureRegion(roundTex, 0, 90 * (i-1), 90, 90);
			stage01Region2[i] = new TextureRegion(roundTex, 90, 90 * (i-1), 90, 90);
			
			stage02Region[i] = new TextureRegion(roundTex, 180, 90 * (i-1), 90, 90);
			stage02Region2[i] = new TextureRegion(roundTex, 270, 90 * (i-1), 90, 90);
			
			stage03Region[i] = new TextureRegion(roundTex, 360, 90 * (i-1), 90, 90);
			stage03Region2[i] = new TextureRegion(roundTex, 450, 90 * (i-1), 90, 90);
			
			stage04Region[i]= new TextureRegion(roundTex, 540, 90 * (i-1), 90, 90);
			stage04Region2[i] = new TextureRegion(roundTex, 630, 90 * (i-1), 90, 90);
			stage05Region[i] = new TextureRegion(roundTex, 720, 90*(i-1), 90, 90);
			stage05Region2[i] = new TextureRegion(roundTex, 810, 90*(i-1), 90, 90);
			
		}
		
//		stage0402Region = new TextureRegion(roundTex, 540, 90, 90, 90);
//		stage0403Region = new TextureRegion(roundTex, 540, 180, 90, 90);
//		stage0404Region = new TextureRegion(roundTex, 540, 270, 90, 90);
//		stage0405Region = new TextureRegion(roundTex, 540, 360, 90, 90);

//		stage0401Region2 = new TextureRegion(roundTex, 630, 0, 90, 90);
//		stage0402Region2 = new TextureRegion(roundTex, 630, 90, 90, 90);
//		stage0403Region2 = new TextureRegion(roundTex, 630, 180, 90, 90);
//		stage0404Region2 = new TextureRegion(roundTex, 630, 270, 90, 90);
//		stage0405Region2 = new TextureRegion(roundTex, 630, 360, 90, 90);

		// round 05
//		stage0501Region = new TextureRegion(roundTex, 720, 0, 90, 90);
//		stage0502Region = new TextureRegion(roundTex, 720, 90, 90, 90);
//		stage0503Region = new TextureRegion(roundTex, 720, 180, 90, 90);
//		stage0504Region = new TextureRegion(roundTex, 720, 270, 90, 90);
//		stage0505Region = new TextureRegion(roundTex, 720, 360, 90, 90);

//		stage0501Region2 = new TextureRegion(roundTex, 810, 0, 90, 90);
//		stage0502Region2 = new TextureRegion(roundTex, 810, 90, 90, 90);
//		stage0503Region2 = new TextureRegion(roundTex, 810, 180, 90, 90);
//		stage0504Region2 = new TextureRegion(roundTex, 810, 270, 90, 90);
//		stage0505Region2 = new TextureRegion(roundTex, 810, 360, 90, 90);

	}

	public static void initBattleTextures() {
		// Battle Screen
		Gdx.app.log("LOADING", String.valueOf(4));

		
		
		texLaser = new Texture(Gdx.files.internal("player/laserbeam.png"));
		texNewModePlayer = new Texture(Gdx.files.internal("player/playernewmode.png"));
		texNewModeButton = new Texture(Gdx.files.internal("button/buttonnewmode.png"));
		
		
//		texGreenSlime = new TextureRegion(kuman,0,128*5 + 64,64*4,64);
//		texBlueSlime =  new TextureRegion(kuman,64*3,128*5 ,64*4,64);
//		texRedSlime =  new TextureRegion(kuman,0,128*6,64*4,64);
//		texOrangeSlime = new TextureRegion(kuman,64*3,128*5 + 64,64*4,64);
//		texLittleGomu  = new TextureRegion(kuman,128,128*3 ,64*2,64);
//		texGomuGomu =  new TextureRegion(kuman,128*3,128*3 ,64*2,64);
//		texGomuKing = new TextureRegion(kuman,128*2,128*3 ,64*2,64);
//		texBoguriWarrior = new TextureRegion(kuman,0,128*5 + 64,64*8,64);
//		texBoguriChieftain  = new TextureRegion(kuman,0,128*6 + 64,64*8,64);
//		texInsaneBoguri  = new TextureRegion(kuman,0,128*6,64*8,64);
//		texBlueRepetol = new TextureRegion(kuman,128,128*3 + 64,64*4,64);
//		texRedRepetol = new TextureRegion(kuman,128*2,128*3 + 64,64*2,64);
//		texVioletRepetol = new TextureRegion(kuman,0,128*4,64*4,64);
		

		texGreenSlime = new Texture(Gdx.files.internal("kuman/slime/slime_green.png"));
		texBlueSlime = new Texture(Gdx.files.internal("kuman/slime/slime_blue.png"));
		texRedSlime = new Texture(Gdx.files.internal("kuman/slime/slime_red.png"));
		texOrangeSlime = new Texture(Gdx.files.internal("kuman/slime/slime_orange.png"));
		texLittleGomu  = new Texture(Gdx.files.internal("kuman/duri/duri_green.png"));
		texGomuGomu = new Texture(Gdx.files.internal("kuman/duri/duri_violet.png"));
		texGomuKing = new Texture(Gdx.files.internal("kuman/duri/duri_orange.png"));
		texBoguriWarrior = new Texture(Gdx.files.internal("kuman/gebuk/gebuk_green.png"));
		texBoguriChieftain = new Texture(Gdx.files.internal("kuman/gebuk/gebuk_red.png"));
		texInsaneBoguri = new Texture(Gdx.files.internal("kuman/gebuk/gebuk_pink.png"));
		texBlueRepetol = new Texture(Gdx.files.internal("kuman/petelur/petelur_blue.png"));
		texRedRepetol = new Texture(Gdx.files.internal("kuman/petelur/petelur_yellow.png"));
		texVioletRepetol = new Texture(Gdx.files.internal("kuman/petelur/petelur_violet.png"));
		
		
		
		texBlack = new Texture(Gdx.files.internal("black/black_right.png"));
		texBlack2 = new Texture(Gdx.files.internal("black/black_right2.png"));
		texBlack3 = new Texture(Gdx.files.internal("black/black_right3.png"));
		texBlack4 = new Texture(Gdx.files.internal("black/black_right4.png"));
		
		storyEndingTex = new Texture(Gdx.files.internal("ending.png")) ;	
		henshinTex = new Texture(Gdx.files.internal("story1b.png"));
		
		
//		texImmunity  = new TextureRegion(buttonDll,64*8 + 160,64*7 + 64,128,64);
		texImmunity  = new Texture(Gdx.files.internal("dll/immunity.png"));
		
		texB = new Texture(Gdx.files.internal("dll/arena.png"));

		
		texTime = angka;
		
//		
//		texBrain = new TextureRegion(organmenulayout,0,0,341,256);
//		texKidney = new TextureRegion(organmenulayout,0,256*2 + 512,128,256);
//		texLiver  = new TextureRegion(organmenulayout,0,256 + 512,256,256);
//		texLung  = new TextureRegion(organmenulayout,0,256,341,512);
//		
//		// Battle Menu Resources
//	
//		
//
//		battleDialog = new TextureRegion(playerdialog, 256*3, 256, 256, 128);
//		winDialog = new TextureRegion(playerdialog, 0, 256, 256, 128);
//		failedDialog = new TextureRegion(playerdialog, 256*2, 256, 256, 128);
//		
//		helpButton = new TextureRegion[2];
//		helpButton[0] = new TextureRegion(buttonDll, 64*7, 64, 32, 32);
//		helpButton[1] = new TextureRegion(buttonDll, 64*7+32, 64, 32, 32);
//		retryButton = new TextureRegion[2];
//		retryButton[0] = new TextureRegion(buttonDll, 64*7, 64*2, 32, 32);
//		retryButton[1] = new TextureRegion(buttonDll, 64*7+32, 64*2, 32, 32);
//		returnPlayButton = new TextureRegion[2];
//		returnPlayButton[0] = new TextureRegion(buttonDll, 64*6, 64+32, 32,
//				32);
//		returnPlayButton[1] = new TextureRegion(buttonDll, 64*6+32, 64+32, 32,
//				32);
//		mainMenuButton = new TextureRegion[2];
//		mainMenuButton[0] = new TextureRegion(buttonDll, 64*7, 64+32, 32, 32);
//		mainMenuButton[1] = new TextureRegion(buttonDll, 64*7+32, 64+32, 32, 32);
//		
//		nextRoundButton = new TextureRegion[2];
//		nextRoundButton[0] = new TextureRegion(buttonDll, 64*6, 64*2, 32, 32);
//		nextRoundButton[1] = new TextureRegion(buttonDll, 64*6+32, 64*2, 32, 32);

		// Story Tutorial Resources
		story = new TextureRegion [8];
		story[1] = new TextureRegion(storyhelpscreen,0,0,480*3,320);
		story[2] = new TextureRegion(storyhelpscreen,0,320,480*2,320);
		story[3] = new TextureRegion(storyhelpscreen,480*2,320,480*2,320);
		story[4] = new TextureRegion(storyhelpscreen,0,320*2,480*2,320);
		story[5] = new TextureRegion(storyhelpscreen,480*2,320*2,480*2,320);
		story[6] = new TextureRegion(storyhelpscreen,0,320*3,480*2,320);
		
		
		
		henshin = new TextureRegion[8];
		
		henshin[0] = new TextureRegion(henshinTex,0,0,120,80);
		henshin[1] = new TextureRegion(henshinTex,120,0,120,80);
		henshin[2] = new TextureRegion(henshinTex,120*2,0,120,80);
		henshin[3] = new TextureRegion(henshinTex,120*3,0,120,80);
		henshin[4] = new TextureRegion(henshinTex,120*4,0,120,80);
		henshin[5] = new TextureRegion(henshinTex,120*5,0,120,80);
		henshin[6] = new TextureRegion(henshinTex,120*6,0,120,80);
		henshin[7] = new TextureRegion(henshinTex,120*7,0,120,80);
		
		
	
		
		story[7] = new TextureRegion(storyEndingTex,0,0,2604,320);
		
		
		
		// story
		helpMenuBg = new TextureRegion(storyhelpscreen,480*3,320*4,480,320);
		
		help = new TextureRegion[6];
		help[1] = new TextureRegion(storyhelpscreen,480*2,320*3,480,320);
		help[2] = new TextureRegion(storyhelpscreen,480*3,320*3,480,320);
		help[3] = new TextureRegion(storyhelpscreen,0,320*4,480,320);
		help[4] = new TextureRegion(storyhelpscreen,480,320*4,480,320);
		help[5] = new TextureRegion(storyhelpscreen,480*2,320*4,480,320);
		

	}

	public static void initSounds() {
		Gdx.app.log("LOADING", String.valueOf(5));
		clickSound = Gdx.audio.newSound(Gdx.files.internal("sfx/button.mp3"));
		 backSound= Gdx.audio.newSound(Gdx.files.internal("sfx/back.mp3"));
		lockedSound= Gdx.audio.newSound(Gdx.files.internal("sfx/locked.mp3"));
		orbSound= Gdx.audio.newSound(Gdx.files.internal("sfx/orb.mp3"));
		timeUpSound= Gdx.audio.newSound(Gdx.files.internal("sfx/timeup.mp3"));
		petelurSound= Gdx.audio.newSound(Gdx.files.internal("sfx/petelur.mp3"));
		punchNoHitSound= Gdx.audio.newSound(Gdx.files.internal("sfx/punchnothit.mp3"));
		loseSound =  Gdx.audio.newSound(Gdx.files.internal("sfx/lose.wav"));
		
		swingSound=  Gdx.audio.newSound(Gdx.files.internal("sfx/swing.wav"));
//		swingSound = new AndroidAudio()
		
		
		bgmOpening = Gdx.audio.newMusic(Gdx.files
				.internal("bgm/bgmopening.mp3"));
		bgmOpening.setLooping(true);
		bgmOpening.setVolume(0.5f);

		bgmViroBook = Gdx.audio.newMusic(Gdx.files
				.internal("bgm/bgmvirobook.mp3"));
		bgmViroBook.setLooping(true);
		bgmViroBook.setVolume(0.5f);
		
		bgmBattle = Gdx.audio.newMusic(Gdx.files
				.internal("bgm/bgmbattle.mp3"));
		bgmBattle.setLooping(true);
		bgmBattle.setVolume(0.5f);
		
		bgmBoss = Gdx.audio.newMusic(Gdx.files
				.internal("bgm/bgmboss.mp3"));
		bgmBoss.setLooping(true);
		bgmBoss.setVolume(0.5f);
		
		bgmEnding = Gdx.audio.newMusic(Gdx.files
				.internal("bgm/bgmending.mp3"));
		bgmEnding.setLooping(true);
		bgmEnding.setVolume(0.5f);
		
		bgmStory = Gdx.audio.newMusic(Gdx.files
				.internal("bgmstory.mp3"));
		bgmStory.setLooping(true);
		bgmStory.setVolume(0.5f);

		Gdx.app.log("LOADING", "Selesai");
		
		

		finish = true;
	}


	@Override
	protected void finalize() throws Throwable {
		super.finalize();

	}

	public static void releaseAllResources() {

		batch.dispose();
		 
		kuman.dispose();
		playerdialog.dispose();
		storyhelpscreen.dispose();
		buttonDll.dispose();

		
		 angka.dispose();
		
		
		
			 
	
		 
		 storyEndingTex.dispose();

	
		 texB.dispose();
		 texLaser.dispose();
	
	
		
		 texBlack.dispose();

		 
			 
	
		stopAllMusics();


		clickSound.dispose();
		backSound.dispose();
		lockedSound.dispose();
		orbSound.dispose();
		timeUpSound.dispose();
		petelurSound.dispose();
		punchNoHitSound.dispose();
		loseSound.dispose();
		
		

		 bgmOpening.dispose();
		 bgmViroBook.dispose();
		 bgmBattle.dispose();
		 bgmBoss.dispose();
		 bgmEnding.dispose();
		 bgmStory.dispose();


	}

	public static void playSound(Sound sound) {
		if (finish)
			if (Settings.soundEnabled)
				sound.play(1);
	}
	

	public static void playMusic(Music music) {
		if (Settings.soundEnabled)
			if (!music.isPlaying()) {
				music.play();
			}
	}

	public static void stopMusic(Music music) {
		if (music.isPlaying()) {
			music.stop();
		}
	}

	public static void pauseAllMusics() {
		if (finish) {

			if (bgmOpening.isPlaying()) {
				bgmOpening.pause();
			}
			if (bgmViroBook.isPlaying()) {
				bgmViroBook.pause();
			}
			if (bgmBattle.isPlaying()) {
				bgmBattle.pause();
			}
			if (bgmEnding.isPlaying()) {
				bgmEnding.pause();
			}
			if (bgmBoss.isPlaying()) {
				bgmBoss.pause();
			}
			if (bgmStory.isPlaying()) {
				bgmStory.pause();
			}
			
		}
	}

	public static void stopAllMusics() {
		if (finish) {
			if (bgmOpening.isPlaying()) {
				bgmOpening.stop();
			}
			if (bgmViroBook.isPlaying()){
				bgmViroBook.stop();
			}
			if (bgmBattle.isPlaying()) {
				bgmBattle.stop();
			}
			if (bgmEnding.isPlaying()) {
				bgmEnding.stop();
			}
			if (bgmBoss.isPlaying()) {
				bgmBoss.stop();
			}
			if (bgmStory.isPlaying()) {
				bgmStory.stop();
			}
			
		}
	}

	public static void resumeAllMusics() {
		int state = MainAppListener.state;
		// masih bug
		if (finish) {
			if (Settings.soundEnabled) {
				if ((state == MainAppListener.MAIN_MENU)
						|| (state == MainAppListener.STAGE_1_ROUND)
						|| (state == MainAppListener.STAGE_2_ROUND)
						|| (state == MainAppListener.STAGE_3_ROUND)
						|| (state == MainAppListener.STAGE_4_ROUND)
						|| (state == MainAppListener.STAGE_5_ROUND)
						|| (state == MainAppListener.STAGE_SELECTION)
						|| (state == MainAppListener.CREDIT)) {
					if (!bgmOpening.isPlaying()) {
						bgmOpening.play();

					}
				} else if ((state >= MainAppListener.BATTLE)
						&& (state <= MainAppListener.BATTLE_5)) {
					if (!bgmBattle.isPlaying()) {
						bgmBattle.play();
					}
					
				} else if ((state >= MainAppListener.STORY_1)
						&& (state <= MainAppListener.STORY_5)) {
					if (!bgmStory.isPlaying()) {
						bgmStory.play();
					}
				}else if ((state == MainAppListener.VIRO)) {
					if (!bgmViroBook.isPlaying()) {
						bgmViroBook.play();
						
					}

				}else if (state == MainAppListener.BATTLE_END){
					if (!bgmBoss.isPlaying()) {
						bgmBoss.play();
					}
				}

			}
		}
	}

	public static void drawAngka(String angka, int x, int y, boolean red) {
		batch.begin();
		if (red) {
			for (int i = 0; i < angka.length(); i++) {
				int j = Integer.parseInt(String.valueOf(angka.charAt(i)));
				batch.draw(angkaMerah[j], x, y);
				x += 20;
			}
		} else {
			for (int i = 0; i < angka.length(); i++) {
				int j = Integer.parseInt(String.valueOf(angka.charAt(i)));
				batch.draw(angkaHijau[j], x, y);
				x += 20;
			}
		}
		batch.end();

	}

	public static void drawTitikDua(int x, int y, boolean red) {
		batch.begin();
		if (red) {
			batch.draw(angkaMerah[10], x, y);
		} else {
			batch.draw(angkaHijau[10], x, y);
		}
		batch.end();
	}

	public static void drawString(String string, int x, int y) {
		String alphabet = "abcdefghijklmnopqrstuvwxyz";
		String Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		
		
//		batch.begin();
	
//		for (int i = 0; i< string.length();i++){
//			CharSequence c = (CharSequence)string.charAt(0);
//			if (alphabet.contains(c)){
//				
//			}
//		}
		
//		batch.end();
	}
////	
//	public static final int SOUND_SWING = 1;
//
//	private static SoundPool soundPool;
//	private static HashMap<Integer, Integer> soundPoolMap;
//
//	private void initSoundPool() {
//	     soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 100);
//	     soundPoolMap = new HashMap<Integer, Integer>();
//	     soundPoolMap.put(SOUND_SWING, soundPool.load(mainListener.mcontext, R..explosion, 1));
//	}
//	          
//	public void playSound(int sound) {
//	    /* Updated: The next 4 lines calculate the current volume in a scale of 0.0 to 1.0 */
//	    AudioManager mgr = (AudioManager)getContext().getSystemService(Context.AUDIO_SERVICE);
//	    float streamVolumeCurrent = mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
//	    float streamVolumeMax = mgr.getStreamMaxVolume(AudioManager.STREAM_MUSIC);    
//	    float volume = streamVolumeCurrent / streamVolumeMax;
//	    
//	    /* Play the sound with the correct volume */
//	    soundPool.play(soundPoolMap.get(sound), volume, volume, 1, 0, 1f);     
//	}
//
//	public void explode() {
//	    playSound(SOUND_EXPLOSION);
//	} 


}
